package com.kyxx.mycommonproject.wodedingdan;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.kyxx.mycommonproject.R;
import com.kyxx.mycommonproject.base.BaseActivity0;

import java.util.ArrayList;
import java.util.List;

public class MyOrderActivity extends BaseActivity0 {
    private TabLayout tl;
    private ViewPager vp;
    private String[] titles = new String[]{"全部", "待付款", "待发货", "待收货", "待评价"};

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.activity_my_order);
    }

    @Override
    protected void findViewById() {
        tl = (TabLayout) findViewById(R.id.tl);
        vp = (ViewPager) findViewById(R.id.vp);
    }

    @Override
    protected void setListener() {
    }

    @Override
    protected void processLogic() {
        loadToolBar("我的订单");
        List<Fragment> fragments = new ArrayList<Fragment>();
        MyOrderFragment myOrderFragment0 = new MyOrderFragment();
        myOrderFragment0.setKey("全部");
        fragments.add(myOrderFragment0);
        MyOrderFragment myOrderFragment1 = new MyOrderFragment();
        myOrderFragment1.setKey("待付款");
        fragments.add(myOrderFragment1);
        MyOrderFragment myOrderFragment2 = new MyOrderFragment();
        myOrderFragment2.setKey("待发货");
        fragments.add(myOrderFragment2);
        MyOrderFragment myOrderFragment3 = new MyOrderFragment();
        myOrderFragment3.setKey("待收货");
        fragments.add(myOrderFragment3);
        MyOrderFragment myOrderFragment4 = new MyOrderFragment();
        myOrderFragment4.setKey("待评价");
        fragments.add(myOrderFragment4);
        vp.setAdapter(new TabFragmentAdapter(fragments, titles, getSupportFragmentManager(), context));
        tl.setupWithViewPager(vp);
        tl.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                vp.setCurrentItem(tab.getPosition(), false);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }
}
